<%@ page import="com.party.core.model.system.TargetType" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>
        ${member.id == null ? '添加' : '编辑'}合作商
    </title>
    <%@include file="../../include/commonFile.jsp" %>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/ui/system/member/member_form.css">
</head>
<body>
<!--头部-->
<%@include file="../../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <!-- 正文请写在这里 -->
            <div class="layui-tab layui-tab-brief" lay-filter="tabSwitch">
                <ul class="layui-tab-title" style="margin-bottom: 20px;">
                    <li id="base" class="layui-this"><span class="title f18 ml5 mr5">基本信息</span></li>
                    <li id="account"><span class="title f18 ml5 mr5">提现账号</span></li>
                    <c:if test="${not empty member.id}">
                        <li><span class="title f18 ml5 mr5">修改密码</span></li>
                        <li><span class="title f18 ml5 mr5">修改退款密码</span></li>
                    </c:if>
                </ul>
                <div class="layui-tab-content">

                    <%--基本信息--%>
                    <div class="layui-tab-item layui-show">
                        <form id="infoForm" class="layui-form mt20" method="post"
                              action="${ctx}/member/group/savePartner.do">
                            <input type="hidden" name="member.id" value="${member.id}"/>
                            <c:if test="${not empty memberGroupInfo.id}">
                                <input type="hidden" name="memberGroupInfo.id" value="${memberGroupInfo.id}"/>
                            </c:if>
                            <table>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">账号<span
                                                        class="f-verify-red">*</span></label>
                                                <div class="layui-input-inline">
                                                    <c:choose>
                                                        <c:when test="${empty member.id}">
                                                            <input class="layui-input" name="username"
                                                                   lay-verify="username"
                                                                   placeholder="账号" value='${member.username}'/>
                                                        </c:when>
                                                        <c:when test="${not empty member.id}">
                                                            <c:if test="${empty member.username}">
                                                                <input class="layui-input" name="username"
                                                                       lay-verify="username"
                                                                       placeholder="账号" value='${member.username}'/>
                                                            </c:if>
                                                            <c:if test="${not empty member.username}">
                                                                <div style="height: 38px; line-height: 38px;">${member.username}</div>
                                                                <input type="hidden" name="username"
                                                                       value='${member.username}'/>
                                                            </c:if>
                                                        </c:when>
                                                    </c:choose>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">客户姓名
                                                    <c:if test="${memberPartner.partnerType!= 4}">
                                                        <span class="f-verify-red">*</span>
                                                    </c:if>
                                                </label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="fullname" lay-verify="fullname"
                                                           placeholder="客户姓名" value='${member.fullname}'/>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">系统简称<span class="f-verify-red">*</span></label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="realname" lay-verify="realname"
                                                           placeholder="系统简称" value='${member.realname}'/>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">客户职务</label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="jobTitle" lay-verify="jobTitle"
                                                           placeholder="客户职务" value='${member.jobTitle}'/>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">公司全称
                                                    <span class="f-verify-red">*</span>
                                                </label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="company" placeholder="公司全称"
                                                           lay-verify="company"
                                                           value="${member.company}">
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">客户电话<span class="f-verify-red">*</span></label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="customerPhone" placeholder="客户电话"
                                                           lay-verify="customerPhone"
                                                           value="${memberGroupInfo.customerPhone}">
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">公司logo</label>
                                            <div class="cover-content">
                                                <input type="hidden" name="logo" id="pic" lay-verify="pic"
                                                       value="${(member.logo == null || empty member.logo) ? 'http://txzapp-10052192.image.myqcloud.com/1490783498894':member.logo}"/>
                                                <c:if test="${member == null || empty member.logo}">
                                        <span id="cover-img" class="round-img"
                                              style="background-image:url(http://txzapp-10052192.image.myqcloud.com/1490783498894)"></span>
                                                </c:if>
                                                <c:if test="${member != null && not empty member.logo}">
                                        <span id="cover-img" class="round-img"
                                              style="background-image:url('${member.logo}')"></span>
                                                </c:if>
                                                <a class="layui-btn layui-btn-danger" id="sel_pic_img">+添加logo</a>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">签约人
                                                    <c:if test="${memberPartner.partnerType!= 4}">
                                                        <span class="f-verify-red">*</span>
                                                    </c:if></label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="contractor" placeholder="签约人"
                                                           lay-verify="contractor"
                                                           value="${memberGroupInfo.contractor}">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">签约时间
                                                    <c:if test="${memberPartner.partnerType!= 4}">
                                                        <span class="f-verify-red">*</span>
                                                    </c:if>
                                                </label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="strSigningTime"
                                                           lay-verify="strSigningTime" id="strSigningTime" readonly
                                                           value='<fmt:formatDate value="${memberGroupInfo.signingTime==null ? signingTime: memberGroupInfo.signingTime}" pattern="yyyy-MM-dd HH:mm" />'/>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">合作商类型</label>
                                                <div class="layui-input-inline" style="width: 455px">
                                                    <input type="radio" name="partnerType" value="0" title="系统客户"
                                                           lay-filter="partnerType"
                                                    ${memberPartner == null || memberPartner.partnerType == 0 ? 'checked="checked"' : ''}
                                                    >
                                                    <input type="radio" name="partnerType" value="1" title="大客户"
                                                           lay-filter="partnerType"
                                                    ${memberPartner != null && memberPartner.partnerType == 1 ? 'checked="checked"' : ''}
                                                    >
                                                    <input type="radio" name="partnerType" value="2" title="地接客户"
                                                           lay-filter="partnerType"
                                                    ${memberPartner != null && memberPartner.partnerType == 2 ? 'checked="checked"' : ''}
                                                    >
                                                    <input type="radio" name="partnerType" value="3" title="运营客户"
                                                           lay-filter="partnerType"
                                                    ${memberPartner != null && memberPartner.partnerType == 3 ? 'checked="checked"' : ''}
                                                    >
                                                    <c:if test="${memberPartner!=null && memberPartner.partnerType == 4}">
                                                        <input type="radio" name="partnerType" value="4" title="注册客户"
                                                               lay-filter="partnerType"
                                                            ${memberPartner.partnerType == 4 ? 'checked="checked"' : ''}
                                                        >
                                                    </c:if>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">合同编号
                                                    <c:if test="${memberPartner.partnerType!= 4}">
                                                        <span class="f-verify-red">*</span>
                                                    </c:if>
                                                </label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="contractNo" placeholder="合同编号"
                                                           lay-verify="contractNo"
                                                           value="${memberGroupInfo.contractNo}">
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item" id="serviceChargeItem"
                                             style="${memberPartner != null && memberPartner.partnerType != 0 && memberPartner.partnerType != 4 ? 'display: inline' : 'display: none'}">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">服务费（每人）</label>
                                                <div class="layui-input-inline">
                                                    <input type="number" name="serviceCharge" placeholder="服务费"
                                                           lay-verify="serviceCharge"
                                                           autocomplete="off" class="layui-input" min="0"
                                                           value="${memberGroupInfo.serviceCharge}">
                                                </div>
                                                <label class="layui-form-mid">元</label>
                                            </div>
                                        </div>

                                        <div class="layui-form-item" id="withdrawalCharge"
                                             style="${memberPartner == null || memberPartner.partnerType == 0 || memberPartner.partnerType == 4 ? 'display: inline' : 'display: none'}">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">提现手续费（每笔）</label>
                                                <div class="layui-input-inline">
                                                    <input type="number" name="withdrawalCharge"
                                                           lay-verify="withdrawalCharge"
                                                           autocomplete="off" placeholder="提现手续费" class="layui-input"
                                                           min="1"
                                                           value="${memberGroupInfo.withdrawalCharge}">
                                                </div>
                                                <div class="layui-form-mid layui-word-aux">%</div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">合同期限
                                                    <c:if test="${memberPartner.partnerType!= 4}">
                                                        <span class="f-verify-red">*</span>
                                                    </c:if>
                                                </label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" placeholder="开始日期"
                                                           name="strContractStartTime"
                                                           lay-verify="strContractStartTime"
                                                           id="strContractStartTime" readonly
                                                           value='<fmt:formatDate value="${memberGroupInfo.contractStartTime==null? contractStartTime:memberGroupInfo.contractStartTime}" pattern="yyyy-MM-dd HH:mm" />'/>
                                                </div>
                                                -
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" placeholder="结束日期"
                                                           name="strContractEndTime"
                                                           lay-verify="strContractEndTime"
                                                           id="strContractEndTime" readonly
                                                           value='<fmt:formatDate value="${memberGroupInfo.contractEndTime==null ? contractEndTime:memberGroupInfo.contractEndTime}" pattern="yyyy-MM-dd HH:mm" />'/>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">是否隐藏底部技术支持</label>
                                                <div class="layui-input-inline">
                                                    <input type="radio" name="isHidden" value="1" title="是"
                                                           lay-verify="isHidden"
                                                    ${member != null && member.isHidden == '1' ? 'checked="checked"' : ''}
                                                    >
                                                    <input type="radio" name="isHidden" value="2" title="否"
                                                           lay-verify="isHidden"
                                                    ${member.id == null || member.isHidden == 2 ? 'checked="checked"' : ''}
                                                    >
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">到期时间<span class="f-verify-red">*</span></label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="stringExpirationTime"
                                                           lay-verify="stringExpirationTime"
                                                           id="stringExpirationTime" readonly
                                                           value='<fmt:formatDate value="${memberGroupInfo.expirationTime}" pattern="yyyy-MM-dd HH:mm" />'/>
                                                </div>

                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">技术支持</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" name="technicalSupport" class="layui-input"
                                                           value="${member.technicalSupport==null? '我也要使用众筹系统':member.technicalSupport}">
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">提醒电话<span class="f-verify-red">*</span></label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="mobile" placeholder="手机号"
                                                           lay-verify="mobile"
                                                           value="${member.mobile}">
                                                </div>
                                                <div class="layui-form-mid layui-word-aux">用于接收资金动态等重要通知</div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">是否隐藏底部版权</label>
                                                <div class="layui-input-inline">
                                                    <input type="radio" name="isHiddenCopyright" value="1" title="是"
                                                           lay-verify="isHiddenCopyright"
                                                    ${member != null && member.isHiddenCopyright == '1' ? 'checked="checked"' : ''}
                                                    >
                                                    <input type="radio" name="isHiddenCopyright" value="2" title="否"
                                                           lay-verify="isHiddenCopyright"
                                                    ${member.id == null || member.isHiddenCopyright == 2 ? 'checked="checked"' : ''}
                                                    >
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">注册时间</label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" disabled="disabled"
                                                           value="<fmt:formatDate value="${member.createDate}" pattern="yyyy-MM-dd HH:mm" />">
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div id="recommendDiv" class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">版权简称</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" name="copyrightName" autocomplete="off"
                                                           class="layui-input"
                                                           lay-verify="copyrightName"
                                                           value="${member.copyrightName}" placeholder="如若不填,默认显示系统简称">
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">备注</label>
                                                <div class="layui-input-inline" style="width: 300px;">
                                                    <textarea name="partnerRemark" style="resize:none" placeholder="备注"
                                                              lay-verify="partnerRemark"
                                                              class="layui-textarea">${memberPartner.partnerRemark}</textarea>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"></label>
                                                <div class="layui-input-inline">
                                                    <a href="javascript:void(0)" class="layui-btn layui-btn-danger"
                                                       lay-submit
                                                       lay-filter="infoForm">立即提交</a>
                                                    <a href="javascript:void(0)" class="layui-btn layui-btn-primary"
                                                       onclick="cancelFunction()">取消</a>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>

                    <%--提现账号--%>
                    <div class="layui-tab-item">
                        <form id="bankInfoForm" class="layui-form mt20" method="post"
                              action="${ctx}/system/member/savePartnerAccount.do">
                            <input type="hidden" name="id" value="${account.id}"/>
                            <input type="hidden" name="memberId"
                                   value="${empty account.memberId?member.id:account.memberId}"/>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">公司名称<span class="f-verify-red">*</span></label>
                                    <div class="layui-input-inline" style="width:220px;">
                                        <input type="text" class="layui-input" name="name" lay-verify="name"
                                               placeholder="请准确填写银行卡开卡公司名称" value='${account.name}'/>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">联系人手机/电话<span class="f-verify-red">*</span></label>
                                    <div class="layui-input-inline">
                                        <input type="text" class="layui-input" name="phone" lay-verify="phone"
                                               placeholder="请填写联系人手机/电话" value='${account.phone}'/>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">公司账号<span class="f-verify-red">*</span></label>
                                    <div class="layui-input-inline">
                                        <input type="text" class="layui-input" name="accountNumber"
                                               lay-verify="accountNumber" placeholder="请填写公司账号"
                                               value='${account.accountNumber}'/>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">银行名称<span class="f-verify-red">*</span></label>
                                    <div class="layui-input-inline">
                                        <input type="text" class="layui-input" name="bankName" lay-verify="bankName"
                                               placeholder="请填写开户银行名称" value='${account.bankName}'/>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">开户支行<span class="f-verify-red">*</span></label>
                                    <div class="layui-input-inline" style="width: 520px;">
                                        <input type="text" class="layui-input" name="openedPlace"
                                               lay-verify="openedPlace"
                                               placeholder="请对照银行对账单填写完整支行信息，如：江苏银行杭州西溪小微企业专营支行"
                                               value='${account.openedPlace}'/>
                                    </div>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"></label>
                                    <div class="layui-input-inline">
                                        <button class="layui-btn layui-btn-danger" lay-submit lay-filter="bankInfoForm">
                                            提交
                                        </button>
                                        <button type="reset" class="layui-btn layui-btn-primary"
                                                onclick="cancelFunction()">取消
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>

                    <%--修改密码--%>
                    <div class="layui-tab-item">
                        <form id="pwdForm" class="layui-form mt20" method="post"
                              action="${ctx}/member/group/updatePwd.do">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"></label>
                                    <div class="layui-input-inline">
                                        <span style="color: #aaa">密码只能输入字母或数字</span>
                                    </div>
                                </div>
                            </div>
                            <c:if test="${sessionScope.newCurrentUser.id == member.id}">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">原密码<span class="f-verify-red">*</span></label>
                                        <div class="layui-input-inline">
                                            <input type="password" class="layui-input" name="oldPassword"
                                                   lay-verify="oldPassword" placeholder="原密码"/>
                                        </div>
                                    </div>
                                </div>
                            </c:if>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">新密码<span class="f-verify-red">*</span></label>
                                    <div class="layui-input-inline">
                                        <input type="password" class="layui-input" name="password" lay-verify="password"
                                               placeholder="新密码"/>
                                        <input type="hidden" name="id" value="${member.id}"/>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">确认密码<span class="f-verify-red">*</span></label>
                                    <div class="layui-input-inline">
                                        <input type="password" class="layui-input" name="repassword"
                                               lay-verify="repassword" placeholder="再次确认密码"/>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"></label>
                                    <div class="layui-input-inline">
                                        <button class="layui-btn layui-btn-danger" lay-submit lay-filter="pwdForm">
                                            立即修改
                                        </button>
                                        <button type="reset" class="layui-btn layui-btn-primary"
                                                onclick="cancelFunction()">取消
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>

                    <%--修改退款密码--%>
                    <div class="layui-tab-item">
                        <form id="refundPwd" class="layui-form mt20" method="post"
                              action="${ctx}/system/member/updateRefundPwd.do">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"></label>
                                    <div class="layui-input-inline">
                                        <span style="color: #aaa">密码只能输入字母或数字</span>
                                    </div>
                                </div>
                            </div>
                            <c:if test="${member.isAdmin == 1 && sessionScope.newCurrentUser.id != member.id}">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">原退款密码<span class="f-verify-red">*</span></label>
                                        <div class="layui-input-inline">
                                            <input type="password" class="layui-input" name="oldPassword"
                                                   lay-verify="oldRefundPassword" placeholder="原退款密码"/>
                                        </div>
                                    </div>
                                </div>
                            </c:if>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">新退款密码<span class="f-verify-red">*</span></label>
                                    <div class="layui-input-inline">
                                        <input type="password" class="layui-input" name="newPassword"
                                               lay-verify="newRefundPassword" placeholder="新退款密码"/>
                                        <input type="hidden" name="id" value="${member.id}"/>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">确认退款密码<span class="f-verify-red">*</span></label>
                                    <div class="layui-input-inline">
                                        <input type="password" class="layui-input" name="confirmPassword"
                                               lay-verify="confirmRefundPassword" placeholder="确认新退款密码"/>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"></label>
                                    <div class="layui-input-inline">
                                        <button class="layui-btn layui-btn-danger" lay-submit lay-filter="refundPwd">
                                            立即修改
                                        </button>
                                        <button type="reset" class="layui-btn layui-btn-primary"
                                                onclick="cancelFunction()">取消
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div><!--底部-->
        <%@include file="../../include/footer.jsp" %>
    </section>
</div>
<script>
    $(function () {
        $("#infoForm").find(":input").each(function (index, ele) {
            $(ele).attr('autocomplete', 'off');
        });
        $('#sel_pic_img').click(function () {
            txz.openSelImg({
                min: 1,
                max: 1,
                info: '建议尺寸：120x120',
                type: '<%=TargetType.LOGO.getCode()%>',
                cb: function (imgs) {
                    $('#cover-img').css('background-image', 'url(' + imgs[0].path + ')');
                    $('#pic').val(imgs[0].path);
                }
            })
        })
        layui.use(['form', 'laydate', 'element'], function () {
            var form = layui.form, laydate = layui.laydate, element = layui.element;

            // 在基本信息、提现账号、修改密码、修改退款几个TAB之间切换
            element.on('tab', function (data) {
                var index = data.index;
                var curTab = $('.layui-tab-content div').eq(index);
                $(curTab).addClass('layui-show');
                $(curTab).siblings().removeClass('layui-show');
            });

            form.on('radio(isExpert)', function (data) {
                if (data.value == "1") {
                    $("#recommendDiv").show();
                } else {
                    $("#recommendDiv").hide();
                }
            });

            //服务费项目屏蔽
            form.on('radio(partnerType)', function (data) {
                if (data.value == "0" || data.value == "4") { //系统客户不需要填写服务费

                    //服务费
                    $('[name=serviceCharge]').attr({'lay-verify': ''});
                    $('[name=serviceCharge]').val(0);
                    $("#serviceChargeItem").hide();

                    //提现手续费
                    $('[name=withdrawalCharge]').removeAttr('disabled').attr({'lay-verify': 'withdrawalCharge'});
                    $("#withdrawalCharge").show();


                } else {
                    //服务费
                    $('[name=serviceCharge]').removeAttr('disabled').attr({'lay-verify': 'serviceCharge'});
                    $("#serviceChargeItem").show();


                    //提现手续费
                    $('[name=withdrawalCharge]').attr({'lay-verify': ''});
                    $('[name=withdrawalCharge]').val(0);
                    $("#withdrawalCharge").hide();
                }
                form.render();
            });

            //自定义验证规则
            form.verify({
                username: function (value) {
                    if (!value) {
                        return '账号不能为空';
                    }
                    if (value.length > 40) {
                        return "账号长度大于40";
                    }
                    if (value != "") {
                        if (!util.checkEmail(value) && !util.checkUserName(value)) {
                            return "账号可以是邮箱或只能以字母开头、可带数字、@和下划线";
                        } else {
                            var isRepeat = txz.checkGroupIsUnique('username', value, '${member.id}');
                            if (undefined == isRepeat) {
                                return "验证用户名异常";
                            } else if (isRepeat) {
                                return "用户名已存在";
                            }
                        }
                    }
                },
                realname: function (value) {
                    if (!util.isValid(value)) {
                        return '请填写系统简称';
                    }
                    if (value.length > 20) {
                        return "系统简称长度大于20";
                    }
                },
                jobTitle: function (value) {
                    if (util.isValid(value) && value.length > 20) {
                        return "客户职务长度大于20";
                    }
                },
                fullname: function (value) {
                    var partnerTypeVal = $('input[name=partnerType]:checked').val();
                    if (partnerTypeVal != 4) {
                        if (!util.isValid(value)) {
                            return '请填写客户姓名';
                        }
                        if (value.length > 20) {
                            return "客户姓名长度大于20";
                        }
                    }
                },
                company: function (value) {
                    if (!util.isValid(value)) {
                        return '请填写公司全称';
                    }
                    if (value.length > 40) {
                        return "公司全称长度大于40";
                    }
                },
                customerPhone: function (value) {
                    var partnerTypeVal = $('input[name=partnerType]:checked').val();
                    if (partnerTypeVal != 4) {
                        if (!util.isValid(value)) {
                            return "请填写客服手机/电话";
                        }

                        var mb = /^(?:(?:0\d{2,3})-)?(?:\d{7,8})(-(?:\d{3,}))?$/;
                        if (!util.checkMobile(value) && !mb.test(value)) {
                            return "客服手机/电话格式不正确";
                        }
                    }
                },
                contractor: function (value) {
                    var partnerTypeVal = $('input[name=partnerType]:checked').val();
                    if (partnerTypeVal != 4) {
                        if (!util.isValid(value)) {
                            return '请填写签约人';
                        }
                        if (value.length > 20) {
                            return "签约人长度大于20";
                        }
                    }
                },

                strSigningTime: function (value) {
                    var partnerTypeVal = $('input[name=partnerType]:checked').val();
                    if (partnerTypeVal != 4) {
                        if (!util.isValid(value)) {
                            return '请选择签约日期';
                        }
                    }
                },
                contractNo: function (value) {
                    var partnerTypeVal = $('input[name=partnerType]:checked').val();
                    if (partnerTypeVal != 4) {
                        if (!util.isValid(value)) {
                            return '请填写合同编号';
                        }
                        if (value.length > 50) {
                            return "合同编号长度大于50";
                        }
                    }

                },
                serviceCharge: function (value) {
                    var partnerTypeVal = $('input[name=partnerType]:checked').val();
                    //系统客户不需要校验
                    if ((0 != partnerTypeVal) && (4 != partnerTypeVal)) {
                        if (!util.isValid(value)) {
                            return '当前合作商类型需要填写服务费';
                        } else if (!util.checkPrice(value) || value <= 0) {
                            return '服务费格式不正确';
                        }
                    }
                },
                withdrawalCharge: function (value) {
                    var partnerTypeVal = $('input[name=partnerType]:checked').val();
                    if ((0 == partnerTypeVal) || (4 == partnerTypeVal)) {
                        if (util.isValid(value)) {
                            if (!(value >= 1 && value < 100)) {
                                return '请填写正确的提现手续费';
                            }
                        }
                    }
                },
                strContractStartTime: function (value) {
                    var partnerTypeVal = $('input[name=partnerType]:checked').val();
                    if (partnerTypeVal != 4) {
                        if (!util.isValid(value)) {
                            return '请选择合同期限的开始日期';
                        }
                    }
                },
                strContractEndTime: function (value) {
                    var partnerTypeVal = $('input[name=partnerType]:checked').val();
                    if (partnerTypeVal != 4) {
                        if (!util.isValid(value)) {
                            return '请选择合同期限的结束日期';
                        }
                        var endDate = $("[name=strContractStartTime]").val();
                        if (endDate >= value) {
                            return "合同期限的结束日期不能早于开始日期";
                        }
                    }
                },
                stringExpirationTime: function (value) {
                    if (!util.isValid(value)) {
                        return '请选择到期时间';
                    }
                },
                mobile: function (value) {
                    if (!util.isValid(value)) {
                        return '请填写提醒电话';
                    }
                    var username = $("#infoForm").find("[name=username]").val();
                    if (value != "" && !util.checkMobile(value)) {
                        return "请填写正确格式的手机号码";
                    } else if (value != "" && util.checkMobile(value)) {
                        var isRepeat = txz.checkGroupIsUnique('mobile', value, '${member.id}', 2, 'partner');
                        if (undefined == isRepeat) {
                            return "验证手机号异常";
                        } else if (isRepeat) {
                            return "手机号已存在";
                        }
                    }
                },
                copyrightName: function (value) {
                    if (util.isValid(value)) {
                        if (value.length > 15) {
                            return "版权简称长度大于15";
                        }
                    }
                },
                partnerRemark: function (value) {
                    if (util.isValid(value)) {
                        if (value.length > 50) {
                            return "备注长度大于50";
                        }
                    }
                },


                name: function (value) {  //提现账号的公司名称
                    if (!util.isValid(value)) {
                        return "请填写公司名称";
                    }
                },

                phone: function (value) { //提现账号的联系人手机号码
                    if (!util.isValid(value)) {
                        return "请填写联系人手机/电话";
                    }

                    var mb = /^(?:(?:0\d{2,3})-)?(?:\d{7,8})(-(?:\d{3,}))?$/;
                    if (!util.checkMobile(value) && !mb.test(value)) {
                        return "联系人手机/电话格式不正确";
                    }
                },

                accountNumber: function (value) { //提现账号的银行账号
                    if (!util.isValid(value))
                        return "请填写公司的银行账号";
                    if (value.trim().length < 13)
                        return "银行账号格式不正确";
                },

                bankName: function (value) { //提现账号的开户银行名称
                    if (!util.isValid(value))
                        return "请填写开户的银行名称";
                    if (value.trim().length < 4)
                        return "银行名称不符合规则";
                },

                openedPlace: function (value) { //提现账号的银行支行名称
                    if (!util.isValid(value))
                        return "请填写开户的银行支行名称";
                    if (value.trim().length < 6)
                        return "银行支行名称不符合规则";
                },

                oldPassword: function (value) {
                    if (value == "") {
                        return "原密码不能为空";
                    } else {
                        var isRepeat = ajaxSubmit({
                            password: value,
                            userId: '${member.id}'
                        }, "${ctx}/member/group/checkPassword.do");
                        if (isRepeat) {
                            return "原密码错误";
                        }
                    }
                },
                password: function (value) {
                    if (value == "") {
                        return "密码不能为空";
                    } else if (!util.checkPassword(value)) {
                        return "密码格式不正确";
                    }
                },
                repassword: function (value) {
                    var pwd = $("#pwdForm [name=password]").val();
                    if (value == "") {
                        return "确认密码不能为空";
                    } else if (!util.checkPassword(value)) {
                        return "确认密码格式不正确";
                    } else if (pwd != value) {
                        return "确认密码与新密码不匹配";
                    }
                },
                oldRefundPassword: function (value) {
                    if (value == "") {
                        return "原退款密码不能为空";
                    } else if (!util.checkPassword(value)) {
                        return "原退款密码格式不正确";
                    }
                },
                newRefundPassword: function (value) {
                    if (value == "") {
                        return "新退款密码不能为空";
                    } else if (!util.checkPassword(value)) {
                        return "新退款密码格式不正确";
                    }
                },
                confirmRefundPassword: function (value) {
                    var pwd = $("#refundPwd [name=newPassword]").val();
                    if (value == "") {
                        return "确认密码不能为空";
                    } else if (!util.checkPassword(value)) {
                        return "确认密码格式不正确";
                    } else if (pwd != value) {
                        return "确认密码与新密码不匹配";
                    }
                }
            });

            function ajaxSubmit(data, url) {
                var isRepeat = false;
                $.ajax({
                    type: 'POST',
                    async: false, // 使用同步的方法
                    data: data,
                    dataType: 'json',
                    success: function (result) {
                        isRepeat = !result;
                    },
                    url: url
                });
                return isRepeat;
            }

            //监听提交
            form.on('submit(infoForm)', function (data) {
                txz.submitObject(data.elem, function (callBack) {
                    var action = $("#infoForm").attr("action");
                    $.post(action, $('#infoForm').serialize(), function (res) {
                        typeof callBack === 'function' && callBack();
                        if (res.success) {
                            util.layerMsgSuccess("基本信息提交成功", function () {
                                location.href = "${ctx}/system/member/partnerList.do";
                            });
                        } else {
                            util.layerMsgError("基本信息提交失败")
                        }
                    });
                })
                return false;
            });

            // 提交提现账号信息
            form.on('submit(bankInfoForm)', function (data) {
                var id = $('#bankInfoForm [name=id]').val();
                txz.submitObject(data.elem, function (callBack) {
                    var action = $("#bankInfoForm").attr("action");
                    $.post(action, $('#bankInfoForm').serialize(), function (res) {
                        typeof callBack === 'function' && callBack();
                        if (res.success) {
                            util.layerMsgSuccess('提现账号' + (id == '' ? '保存' : '修改') + '成功', function () {
                                window.location.reload();
                            });
                        } else {
                            util.layerMsgError("提现账号" + (id == '' ? '保存' : '修改') + "失败")
                        }
                    });
                })
                return false;
            });

            //监听提交 修改密码
            form.on('submit(pwdForm)', function (data) {
                txz.submitObject(data.elem, function (callBack) {
                    var action = $("#pwdForm").attr("action");
                    $.post(action, $('#pwdForm').serialize(), function (res) {
                        typeof callBack === 'function' && callBack();
                        if (res.success) {
                            util.layerMsgSuccess('密码修改成功', function () {
                                window.location.reload();
                            });
                        } else {
                            util.layerMsgError("密码修改失败")
                        }
                    });
                })
                return false;
            });

            //监听提交 修改退款密码
            form.on('submit(refundPwd)', function (data) {
                txz.submitObject(data.elem, function (callBack) {
                    var action = $("#refundPwd").attr("action");
                    $.post(action, $('#refundPwd').serialize(), function (res) {
                        typeof callBack === 'function' && callBack();
                        if (res.success) {
                            util.layerMsgSuccess('退款密码修改成功', function () {
                                window.location.reload();
                            });
                        } else {
                            util.layerMsgError(res.description)
                        }
                    });
                })
                return false;
            });
            var end = {
                elem: '#stringExpirationTime',
                min: '2015-01-01 00:00:00',
                max: '2099-06-16 23:59',
                type: 'datetime',
                format: 'yyyy-MM-dd HH:mm' //日期格式
            };
            var strSigningTime = {
                elem: '#strSigningTime',
                min: '2015-01-01',
                max: '2099-06-16 23:59',
                type: 'datetime',
                format: 'yyyy-MM-dd HH:mm' //日期格式
            };
            var strContractStartTime = {
                elem: '#strContractStartTime',
                min: '2015-01-01',
                max: '2099-06-16 23:59',
                type: 'datetime',
                format: 'yyyy-MM-dd HH:mm' //日期格式
            };
            var strContractEndTime = {
                elem: '#strContractEndTime',
                min: '2015-01-01',
                max: '2099-06-16 23:59',
                type: 'datetime',
                format: 'yyyy-MM-dd HH:mm' //日期格式
            };

            laydate.render(strContractStartTime);
            laydate.render(strContractEndTime);
            laydate.render(end);
            laydate.render(strSigningTime);
        });
    })

    function cancelFunction() {
        location.href = "${ctx}/system/member/partnerList.do";
    }
</script>
<script type="text/javascript">
    txz.initHeader({
        nav: [{
            name: '合作商管理',
            href: '${ctx}/system/member/partnerList.do'
        }, {
            name: '${member.id == null ? '添加' : '编辑'}合作商用户',
            curr: true
        }],
        btns: [{
            name: '返回',
            href: 'javascript:history.back();',
            icon: 'back'
        }]
    });
</script>
</body>
</html>